﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Extensions.ByteExtension
{
    public static class ByteExtensions
    {
        /// <summary>
        /// Converts the Byte Array to a String with Default Encoding
        /// </summary>
        /// <param name="ba"></param>
        /// <returns></returns>
        public static string ConvertToString(this byte[] ba)
        {
            return ConvertToString(ba, 0, ba.Length, Encoding.Default);
        }

        /// <summary>
        /// Converts the Byte Array to a String with Defaul Encoding from 
        /// an index to a specified Element count
        /// </summary>
        /// <param name="ba"></param>
        /// <param name="index"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static string ConvertToString(this byte[] ba, int index, int count)
        {
            return Encoding.Default.GetString(ba, index, count);
        }

        /// <summary>
        /// Converts the Byte Array to a String for an index of the byte array,
        /// to a specified Element and in a specified Encoding
        /// </summary>
        /// <param name="ba"></param>
        /// <param name="index"></param>
        /// <param name="count"></param>
        /// <param name="standart"></param>
        /// <returns></returns>
        public static string ConvertToString(this byte[] ba, int index, int count, Encoding standart)
        {
            return standart.GetString(ba, index, count);
        }
    }
}
